package com.swz.dcrm.ui.analyze;


import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.swz.dcrm.adpter.GlobalAdapter;
import com.swz.dcrm.ui.base.BaseFragment;
import com.swz.dcrm.R;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.navigation.fragment.NavHostFragment;

import android.widget.TextView;

import butterknife.BindView;
import butterknife.OnClick;

import com.swz.dcrm.R;

/**
 * A simple {@link Fragment} subclass.
 */
public class BusinessAnalysisFragment extends BaseFragment {

    @BindView(R.id.toolbar_title)
    TextView title;


    public static BusinessAnalysisFragment newInstance() {

        return new BusinessAnalysisFragment();
        // Required empty public constructor
    }

    @Override
    public void onLoadRetry() {
        if (!isNetworkConnected(getContext())){
            mHolder.showLoadingStatus(GlobalAdapter.NET_ERROR);
            return;
        }
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        onLoadRetry();
    }

    @Override
    public int layoutId() {
        return R.layout.fragment_business_analysis;
    }

    @Override
    public boolean initView() {
        getDigger().inject(this);
        title.setText(getString(R.string.analysis));
        return true;
    }

    @OnClick({R.id.tv_analysis_type1,R.id.tv_analysis_type2,R.id.tv_analysis_type3,R.id.tv_analysis_type4,R.id.tv_analysis_type5,R.id.tv_analysis_type6,R.id.tv_analysis_type7,R.id.tv_analysis_type8})
    public void go(View view){
        switch (view.getId()){
            case R.id.tv_analysis_type1:
                RankingListFragmentArgs.Builder builder7=new RankingListFragmentArgs.Builder();
                builder7.setTitle(getString(R.string.analysis_type1));
                go(null,R.id.action_businessAnalysisFragment_to_rankingListFragment,builder7.build().toBundle());
                break;
            case R.id.tv_analysis_type2:
                RankingListFragmentArgs.Builder builder6=new RankingListFragmentArgs.Builder();
                builder6.setTitle(getString(R.string.analysis_type2));
                go(null,R.id.action_businessAnalysisFragment_to_rankingListFragment,builder6.build().toBundle());
                break;
            case R.id.tv_analysis_type3:
                RankingListFragmentArgs.Builder builder4=new RankingListFragmentArgs.Builder();
                builder4.setTitle(getString(R.string.analysis_type3));
                go(null,R.id.action_businessAnalysisFragment_to_rankingListFragment,builder4.build().toBundle());
                break;
            case R.id.tv_analysis_type4:
                AnalyzeType5FragmentArgs.Builder builder5=new AnalyzeType5FragmentArgs.Builder();
                builder5.setTitle(getString(R.string.analysis_type4));
                go(null,R.id.action_businessAnalysisFragment_to_analyzeType5Fragment,builder5.build().toBundle());
                break;
            case R.id.tv_analysis_type5:
                AnalyzeType5FragmentArgs.Builder builder2=new AnalyzeType5FragmentArgs.Builder();
                builder2.setTitle(getString(R.string.analysis_type5));
                go(null,R.id.action_businessAnalysisFragment_to_analyzeType5Fragment,builder2.build().toBundle());
                break;
            case R.id.tv_analysis_type6:
                RankingListFragmentArgs.Builder builder=new RankingListFragmentArgs.Builder();
                builder.setTitle(getString(R.string.analysis_type6));
                go(null,R.id.action_businessAnalysisFragment_to_rankingListFragment,builder.build().toBundle());
                break;
            case R.id.tv_analysis_type7:
                RankingListFragmentArgs.Builder builder3=new RankingListFragmentArgs.Builder();
                builder3.setTitle(getString(R.string.analysis_type7));
                go(null,R.id.action_businessAnalysisFragment_to_rankingListFragment,builder3.build().toBundle());
                break;
            case R.id.tv_analysis_type8:
                RankingListFragmentArgs.Builder builder1=new RankingListFragmentArgs.Builder();
                builder1.setTitle(getString(R.string.analysis_type8));
                go(null,R.id.action_businessAnalysisFragment_to_rankingListFragment,builder1.build().toBundle());
                break;
        }
    }
    @OnClick(R.id.iv_back)
    public void backClick() {
        NavHostFragment.findNavController(this).navigateUp();
    }
}
